#include "DropCommand.h"


DropCommand::DropCommand(SQLSystem* sql): Command(sql)
{
}


DropCommand::~DropCommand()
{
}

int DropCommand::execute(const string &str)
{
	SQLSystem* system;
	system= getSystem();
	typedef tokenizer<char_separator<char> > token;
	char_separator<char> sep(" ","",drop_empty_tokens);
	token tok(str, sep);
	token::iterator tok_iter= tok.begin();
	++tok_iter;
	if(tok_iter == tok.end())	
		return false;
	if(helper->toUpperString(*tok_iter) != "TABLE")
	{
		cout << "SYNTAX ERROR\n";
		return false;
	}
	++tok_iter;
	if(tok_iter==tok.end())
	{
		cout << "MISSING TABLE NAME\n";
		return false;
	}
	system->removeTable(*tok_iter);
	cout << "TABLE DROPPED\n";
	return true;

}
